home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWFile.z / RWFile
Encoding:
Text File  |  1998-10-30  |  14.8 KB  |  397 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))                                                      RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWFile - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/rwfile.h>
  13.  
  14.  
  15.  
  16.  
  17.           RWFile f("filename");
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWFFFFiiiilllleeee encapsulates binary file operations using the Standard C
  24.      stream library (functions ffffooooppppeeeennnn(((()))), ffffrrrreeeeaaaadddd(((()))), ffffwwwwrrrriiiitttteeee(((()))), eeeettttcccc....).  This class
  25.      is based on class PPPPFFFFiiiilllleeee of the IIIInnnntttteeeerrrrvvvviiiieeeewwwwssss CCCCllllaaaassssssss LLLLiiiibbbbrrrraaaarrrryyyy (1987, Stanford
  26.      University).  The member function names begin with upper case letters in
  27.      order to maintain compatibility with class PPPPFFFFiiiilllleeee .  Because this class is
  28.      intended to encapsulate bbbbiiiinnnnaaaarrrryyyy operations, it is important that it be
  29.      opened using a binary mode.  This is particularly important under MS-DOS
  30.      -- otherwise bytes that happen to match a newline will be expanded to
  31.      (carriage return, line feed).
  32.  
  33. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  34.      None
  35.  
  36. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  37.               RRRRWWWWFFFFiiiilllleeee(const char* filename, const char* mode = 0);
  38.  
  39.  
  40.      Construct an RRRRWWWWFFFFiiiilllleeee to be used with the file of name ffffiiiilllleeeennnnaaaammmmeeee and with
  41.      mode mmmmooooddddeeee.  The mode is as given by the Standard C library function
  42.      ffffooooppppeeeennnn(((()))).  If mmmmooooddddeeee is zero (the default) then the constructor will attempt
  43.      to open an existing file with the given filename for update (mode "rrrrbbbb++++").
  44.      If this is not possible, then it will attempt to create a new file with
  45.      the given filename (mode "wwwwbbbb++++").  The resultant object should be checked
  46.      for validity using function iiiissssVVVVaaaalllliiiidddd(((()))).
  47.  
  48.               ~RRRRWWWWFFFFiiiilllleeee();
  49.  
  50.  
  51.      Performs any pending I/O operations and closes the file.
  52.  
  53. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  54.               const char*
  55.           AAAAcccccccceeeessssssss();
  56.  
  57.  
  58.      Returns the access mode with which the underlying FFFFIIIILLLLEEEE**** was opened.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))                                                      RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               void
  75.           CCCClllleeeeaaaarrrrEEEErrrrrrrr();
  76.  
  77.  
  78.      Reset error state so that neither EEEEooooffff(((()))) nor EEEErrrrrrrroooorrrr(((()))) returns TTTTRRRRUUUUEEEE.  Calls
  79.      C library function cccclllleeeeaaaarrrreeeerrrrrrrr(((()))).
  80.  
  81.               RWoffset
  82.           CCCCuuuurrrrOOOOffffffffsssseeeetttt();
  83.  
  84.  
  85.      Returns the current position, in bytes from the start of the file, of the
  86.      file pointer.
  87.  
  88.               RWBoolean
  89.           EEEEooooffff();
  90.  
  91.  
  92.      Returns TTTTRRRRUUUUEEEE if an end-of-file has been encountered.
  93.  
  94.               RWBoolean
  95.           EEEErrrraaaasssseeee();
  96.  
  97.  
  98.      Erases the contents but does not close the file.  Returns TTTTRRRRUUUUEEEE if the
  99.      operation was successful.
  100.  
  101.               RWBoolean
  102.           EEEErrrrrrrroooorrrr();
  103.  
  104.  
  105.      Returns TTTTRRRRUUUUEEEE if a file I/O error has occurred as determined by a call to
  106.      the C library function ffffeeeerrrrrrrroooorrrr(((()))).
  107.  
  108.               RWBoolean
  109.           EEEExxxxiiiissssttttssss();
  110.  
  111.  
  112.      Returns TTTTRRRRUUUUEEEE if the file exists.
  113.  
  114.               RWBoolean
  115.           FFFFlllluuuusssshhhh();
  116.  
  117.  
  118.      Perform any pending I/O operations.  Returns TTTTRRRRUUUUEEEE if successful.
  119.  
  120.               const char*
  121.           GGGGeeeettttNNNNaaaammmmeeee();
  122.  
  123.  
  124.      Returns the file name.
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))                                                      RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               FILE*
  141.           GGGGeeeettttSSSSttttrrrreeeeaaaammmm();
  142.  
  143.  
  144.      Returns the FFFFIIIILLLLEEEE**** that underlies the RRRRWWWWFFFFiiiilllleeee interface.  Provided for
  145.      users who need to "get under the hood" for system-dependent inquiries,
  146.      etc.  DDDDoooo nnnnooootttt uuuusssseeee ttttoooo aaaalllltttteeeerrrr tttthhhheeee ssssttttaaaatttteeee ooooffff tttthhhheeee ffffiiiilllleeee!!!!
  147.  
  148.               RWBoolean
  149.           IIIIssssEEEEmmmmppppttttyyyy();
  150.  
  151.  
  152.      Returns TTTTRRRRUUUUEEEE if the file contains no data, FFFFAAAALLLLSSSSEEEE otherwise.
  153.  
  154.               RWBoolean
  155.           iiiissssVVVVaaaalllliiiidddd() const;
  156.  
  157.  
  158.      Returns TTTTRRRRUUUUEEEE if the file was successfully opened, FFFFAAAALLLLSSSSEEEE otherwise.
  159.  
  160.               RWBoolean
  161.           RRRReeeeaaaadddd(char& c);
  162.           RWBoolean
  163.           RRRReeeeaaaadddd(wchar_t& wc);
  164.           RWBoolean
  165.           RRRReeeeaaaadddd(short& i);
  166.           RWBoolean
  167.           RRRReeeeaaaadddd(int& i);
  168.           RWBoolean
  169.           RRRReeeeaaaadddd(long& i);
  170.           RWBoolean
  171.           RRRReeeeaaaadddd(unsigned char& c);
  172.           RWBoolean
  173.           RRRReeeeaaaadddd(unsigned short& i);
  174.           RWBoolean
  175.           RRRReeeeaaaadddd(unsigned int& i);
  176.           RWBoolean
  177.           RRRReeeeaaaadddd(unsigned long& i);
  178.           RWBoolean
  179.           RRRReeeeaaaadddd(float& f);
  180.           RWBoolean
  181.           RRRReeeeaaaadddd(double& d);
  182.  
  183.  
  184.      Reads the indicated built-in type.  Returns TTTTRRRRUUUUEEEE if the read is
  185.      successful.
  186.  
  187.               RWBoolean
  188.           RRRReeeeaaaadddd(char* i,          size_t count);
  189.           RWBoolean
  190.           RRRReeeeaaaadddd(wchar_t* i,       size_t count);
  191.           RWBoolean
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))                                                      RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.           RRRReeeeaaaadddd(short* i,         size_t count);
  207.           RWBoolean
  208.           RRRReeeeaaaadddd(int* i,           size_t count);
  209.           RWBoolean
  210.           RRRReeeeaaaadddd(long* i,          size_t count);
  211.           RWBoolean
  212.           RRRReeeeaaaadddd(unsigned char* i, size_t count);
  213.           RWBoolean
  214.           RRRReeeeaaaadddd(unsigned short* i,size_t count);
  215.           RWBoolean
  216.           RRRReeeeaaaadddd(unsigned int* i,  size_t count);
  217.           RWBoolean
  218.           RRRReeeeaaaadddd(unsigned long* i, size_t count);
  219.           RWBoolean
  220.           RRRReeeeaaaadddd(float* i,         size_t count);
  221.           RWBoolean
  222.           RRRReeeeaaaadddd(double* i,        size_t count);
  223.  
  224.  
  225.      Reads ccccoooouuuunnnntttt instances of the indicated built-in type into a block pointed
  226.      to by iiii.  Returns TTTTRRRRUUUUEEEE if the read is successful.  Note that you are
  227.      responsible for declaring iiii and for allocating the necessary storage
  228.      before calling this function.
  229.  
  230.               RWBoolean
  231.           RRRReeeeaaaadddd(char* string);
  232.  
  233.  
  234.      Reads a character string, including the terminating null character, into
  235.      a block pointed to by ssssttttrrrriiiinnnngggg.  Returns TTTTRRRRUUUUEEEE if the read is successful.
  236.      Note that you are responsible for declaring ssssttttrrrriiiinnnngggg and for allocating the
  237.      necessary storage before calling this function.  Beware of overflow when
  238.      using this function.
  239.  
  240.               RWBoolean
  241.           SSSSeeeeeeeekkkkTTTToooo(RWoffset offset);
  242.  
  243.  
  244.      Repositions the file pointer to ooooffffffffsssseeeetttt bytes from the start of the file.
  245.      Returns TTTTRRRRUUUUEEEE if the operation is successful.
  246.  
  247.               RWBoolean
  248.           SSSSeeeeeeeekkkkTTTTooooBBBBeeeeggggiiiinnnn();
  249.  
  250.  
  251.      Repositions the file pointer to the start of the file.  Returns TTTTRRRRUUUUEEEE if
  252.      the operation is successful.
  253.  
  254.               RWBoolean
  255.           SSSSeeeeeeeekkkkTTTTooooEEEEnnnndddd();
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))                                                      RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      Repositions the file pointer to the end of the file.  Returns TTTTRRRRUUUUEEEE if the
  273.      operation is successful.
  274.  
  275.               RWBoolean
  276.           WWWWrrrriiiitttteeee(char i);
  277.           RWBoolean
  278.           WWWWrrrriiiitttteeee(wchar_t i);
  279.           RWBoolean
  280.           WWWWrrrriiiitttteeee(short i);
  281.           RWBoolean
  282.           WWWWrrrriiiitttteeee(int i);
  283.           RWBoolean
  284.           WWWWrrrriiiitttteeee(long i);
  285.           RWBoolean
  286.           WWWWrrrriiiitttteeee(unsigned char i);
  287.           RWBoolean
  288.           WWWWrrrriiiitttteeee(unsigned short i);
  289.           RWBoolean
  290.           WWWWrrrriiiitttteeee(unsigned int i);
  291.           RWBoolean
  292.           WWWWrrrriiiitttteeee(unsigned long i);
  293.           RWBoolean
  294.           WWWWrrrriiiitttteeee(float f);
  295.           RWBoolean
  296.           WWWWrrrriiiitttteeee(double d);
  297.  
  298.  
  299.      Writes the appropriate built-in type.  Returns TTTTRRRRUUUUEEEE if the write is
  300.      successful.
  301.  
  302.               RWBoolean
  303.           WWWWrrrriiiitttteeee(const char* i,          size_t count);
  304.           RWBoolean
  305.           WWWWrrrriiiitttteeee(const wchar_t* i,       size_t count);
  306.           RWBoolean
  307.           WWWWrrrriiiitttteeee(const short* i,         size_t count);
  308.           RWBoolean
  309.           WWWWrrrriiiitttteeee(const int* i,           size_t count);
  310.           RWBoolean
  311.           WWWWrrrriiiitttteeee(const long* i,          size_t count);
  312.           RWBoolean
  313.           WWWWrrrriiiitttteeee(const unsigned char* i, size_t count);
  314.           RWBoolean
  315.           WWWWrrrriiiitttteeee(const unsigned short* i,size_t count);
  316.           RWBoolean
  317.           WWWWrrrriiiitttteeee(const unsigned int* i,  size_t count);
  318.           RWBoolean
  319.           WWWWrrrriiiitttteeee(const unsigned long* i, size_t count);
  320.           RWBoolean
  321.           WWWWrrrriiiitttteeee(const float* i,         size_t count);
  322.           RWBoolean
  323.           WWWWrrrriiiitttteeee(const double* i,        size_t count);
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))                                                      RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.      Writes ccccoooouuuunnnntttt instances of the indicated built-in type from a block
  339.      pointed to by iiii.  Returns TTTTRRRRUUUUEEEE if the write is successful.
  340.  
  341.               RWBoolean
  342.           WWWWrrrriiiitttteeee(const char* string);
  343.  
  344.  
  345.      Writes a character string, iiiinnnncccclllluuuuddddiiiinnnngggg tttthhhheeee tttteeeerrrrmmmmiiiinnnnaaaattttiiiinnnngggg nnnnuuuullllllll cccchhhhaaaarrrraaaacccctttteeeerrrr, from
  346.      a block pointed to by ssssttttrrrriiiinnnngggg.  Returns TTTTRRRRUUUUEEEE if the write is successful.
  347.      Beware of non-terminated strings when using this function.
  348.  
  349. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  350.               static RWBoolean
  351.           EEEExxxxiiiissssttttssss(const char* filename, int mode = F_OK);
  352.  
  353.  
  354.      Returns TTTTRRRRUUUUEEEE if a file with name ffffiiiilllleeeennnnaaaammmmeeee exists and may be accessed
  355.      according to the mmmmooooddddeeee specified.  The mmmmooooddddeeee may be OOOORRRRed together from one
  356.      or more of:  FFFF____OOOOKKKK:  "Exists" (Implied by any of the others) XXXX____OOOOKKKK:
  357.      "Executable or searchable" WWWW____OOOOKKKK:  "Writable" RRRR____OOOOKKKK:  "Readable" If your
  358.      compiler or operating system does not support the POSIX aaaacccccccceeeessssssss(((())))
  359.      function, then mode XXXX____OOOOKKKK will always return FFFFAAAALLLLSSSSEEEE.
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.